

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>prml.clustering package &mdash; prml  documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
        <script type="text/javascript" src="_static/jquery.js"></script>
        <script type="text/javascript" src="_static/underscore.js"></script>
        <script type="text/javascript" src="_static/doctools.js"></script>
        <script type="text/javascript" src="_static/language_data.js"></script>
        <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="prml.dimreduction package" href="prml.dimreduction.html" />
    <link rel="prev" title="prml.bayesnet package" href="prml.bayesnet.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="index.html" class="icon icon-home"> prml
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="prml.html">prml package</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="prml.html#subpackages">Subpackages</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="prml.bayesnet.html">prml.bayesnet package</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">prml.clustering package</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-prml.clustering.k_means">prml.clustering.k_means module</a></li>
<li class="toctree-l4"><a class="reference internal" href="#module-prml.clustering">Module contents</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="prml.dimreduction.html">prml.dimreduction package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.kernel.html">prml.kernel package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.linear.html">prml.linear package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.markov.html">prml.markov package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.nn.html">prml.nn package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.preprocess.html">prml.preprocess package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.rv.html">prml.rv package</a></li>
<li class="toctree-l3"><a class="reference internal" href="prml.sampling.html">prml.sampling package</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="prml.html#module-prml">Module contents</a></li>
</ul>
</li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">prml</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="index.html">Docs</a> &raquo;</li>
        
          <li><a href="prml.html">prml package</a> &raquo;</li>
        
      <li>prml.clustering package</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="_sources/prml.clustering.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="prml-clustering-package">
<h1>prml.clustering package<a class="headerlink" href="#prml-clustering-package" title="Permalink to this headline">¶</a></h1>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="module-prml.clustering.k_means">
<span id="prml-clustering-k-means-module"></span><h2>prml.clustering.k_means module<a class="headerlink" href="#module-prml.clustering.k_means" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="prml.clustering.k_means.KMeans">
<em class="property">class </em><code class="descclassname">prml.clustering.k_means.</code><code class="descname">KMeans</code><span class="sig-paren">(</span><em>n_clusters</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/prml/clustering/k_means.html#KMeans"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#prml.clustering.k_means.KMeans" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<dl class="method">
<dt id="prml.clustering.k_means.KMeans.fit">
<code class="descname">fit</code><span class="sig-paren">(</span><em>X</em>, <em>iter_max=100</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/prml/clustering/k_means.html#KMeans.fit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#prml.clustering.k_means.KMeans.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>perform k-means algorithm</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>X</strong> (<em>(</em><em>sample_size</em><em>, </em><em>n_features</em><em>) </em><em>ndarray</em>) – input data</li>
<li><strong>iter_max</strong> (<em>int</em>) – maximum number of iterations</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>centers</strong> – center of each cluster</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(n_clusters, n_features) ndarray</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="prml.clustering.k_means.KMeans.predict">
<code class="descname">predict</code><span class="sig-paren">(</span><em>X</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/prml/clustering/k_means.html#KMeans.predict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#prml.clustering.k_means.KMeans.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>calculate closest cluster center index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>X</strong> (<em>(</em><em>sample_size</em><em>, </em><em>n_features</em><em>) </em><em>ndarray</em>) – input data</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>index</strong> – indicates which cluster they belong</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">(sample_size,) ndarray</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-prml.clustering">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-prml.clustering" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="prml.clustering.KMeans">
<em class="property">class </em><code class="descclassname">prml.clustering.</code><code class="descname">KMeans</code><span class="sig-paren">(</span><em>n_clusters</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/prml/clustering/k_means.html#KMeans"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#prml.clustering.KMeans" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<dl class="method">
<dt id="prml.clustering.KMeans.fit">
<code class="descname">fit</code><span class="sig-paren">(</span><em>X</em>, <em>iter_max=100</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/prml/clustering/k_means.html#KMeans.fit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#prml.clustering.KMeans.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>perform k-means algorithm</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>X</strong> (<em>(</em><em>sample_size</em><em>, </em><em>n_features</em><em>) </em><em>ndarray</em>) – input data</li>
<li><strong>iter_max</strong> (<em>int</em>) – maximum number of iterations</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"><strong>centers</strong> – center of each cluster</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">(n_clusters, n_features) ndarray</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="prml.clustering.KMeans.predict">
<code class="descname">predict</code><span class="sig-paren">(</span><em>X</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/prml/clustering/k_means.html#KMeans.predict"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#prml.clustering.KMeans.predict" title="Permalink to this definition">¶</a></dt>
<dd><p>calculate closest cluster center index</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>X</strong> (<em>(</em><em>sample_size</em><em>, </em><em>n_features</em><em>) </em><em>ndarray</em>) – input data</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><strong>index</strong> – indicates which cluster they belong</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body">(sample_size,) ndarray</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="prml.dimreduction.html" class="btn btn-neutral float-right" title="prml.dimreduction package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="prml.bayesnet.html" class="btn btn-neutral float-left" title="prml.bayesnet package" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, Author

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>